using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Resources;
using System.Windows.Forms;
using Infragistics.Win;
using Infragistics.Win.UltraWinDataSource;
using Infragistics.Win.UltraWinGrid;
using PluginFrame;

namespace ExperimentRuleEditor
{
	public class Expression_Editor : Form
	{
		private IContainer components;

		private UltraGrid ultraGridEditor;

		private Button btAdd;

		private Button btCancel;

		private Button btRemove;

		private Button btOk;

		private UltraDataSource ultraDataSource1;

		private Button btAnalysis;

		private IRuleItem m_LRuleItem;

		private string m_LSelectExpression = "";

		private string m_LProjectName;

		private readonly IPcrLogService mPcrLogService;

		private IApplication mApplication;

		protected ResourceManager mResourceManager;

		private int m_LPattern;

		private int m_LTarget;

		private int m_LOperator;

		private string m_LValue;

		private int m_LExpressionCheck;

		public string GetSelectExpressionText
		{
			get
			{
				return m_LSelectExpression;
			}
		}

		public int GetPatternIndex
		{
			get
			{
				return m_LPattern;
			}
		}

		public int GetTargetIndex
		{
			get
			{
				return m_LTarget;
			}
		}

		public int GetExpressionCheck
		{
			get
			{
				return m_LExpressionCheck;
			}
		}

		public int GetOperatorIndex
		{
			get
			{
				return m_LOperator;
			}
		}

		public string GetValueIndex
		{
			get
			{
				return m_LValue;
			}
		}

		protected override void Dispose(bool disposing)
		{
			if (disposing && components != null)
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}

		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ExperimentRuleEditor.Expression_Editor));
			Infragistics.Win.Appearance appearance = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance3 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance4 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance5 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance6 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance7 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance8 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance9 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance10 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance11 = new Infragistics.Win.Appearance();
			this.ultraGridEditor = new Infragistics.Win.UltraWinGrid.UltraGrid();
			this.ultraDataSource1 = new Infragistics.Win.UltraWinDataSource.UltraDataSource(this.components);
			this.btAdd = new System.Windows.Forms.Button();
			this.btCancel = new System.Windows.Forms.Button();
			this.btRemove = new System.Windows.Forms.Button();
			this.btOk = new System.Windows.Forms.Button();
			this.btAnalysis = new System.Windows.Forms.Button();
			((System.ComponentModel.ISupportInitialize)this.ultraGridEditor).BeginInit();
			((System.ComponentModel.ISupportInitialize)this.ultraDataSource1).BeginInit();
			base.SuspendLayout();
			this.ultraGridEditor.AccessibleDescription = null;
			this.ultraGridEditor.AccessibleName = null;
			resources.ApplyResources(this.ultraGridEditor, "ultraGridEditor");
			this.ultraGridEditor.BackgroundImage = null;
			this.ultraGridEditor.DataSource = this.ultraDataSource1;
			appearance.BackColor = System.Drawing.SystemColors.Window;
			appearance.BorderColor = System.Drawing.Color.White;
			resources.ApplyResources(appearance, "appearance31");
			resources.ApplyResources(appearance.FontData, "appearance31.FontData");
			appearance.ForceApplyResources = "FontData|";
			this.ultraGridEditor.DisplayLayout.Appearance = appearance;
			this.ultraGridEditor.DisplayLayout.BorderStyle = Infragistics.Win.UIElementBorderStyle.Solid;
			this.ultraGridEditor.DisplayLayout.CaptionVisible = Infragistics.Win.DefaultableBoolean.False;
			appearance2.BackColor = System.Drawing.SystemColors.ActiveBorder;
			appearance2.BackColor2 = System.Drawing.SystemColors.ControlDark;
			appearance2.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
			appearance2.BorderColor = System.Drawing.SystemColors.Window;
			resources.ApplyResources(appearance2, "appearance32");
			resources.ApplyResources(appearance2.FontData, "appearance32.FontData");
			appearance2.ForceApplyResources = "FontData|";
			this.ultraGridEditor.DisplayLayout.GroupByBox.Appearance = appearance2;
			appearance3.ForeColor = System.Drawing.SystemColors.GrayText;
			resources.ApplyResources(appearance3, "appearance33");
			resources.ApplyResources(appearance3.FontData, "appearance33.FontData");
			appearance3.ForceApplyResources = "FontData|";
			this.ultraGridEditor.DisplayLayout.GroupByBox.BandLabelAppearance = appearance3;
			this.ultraGridEditor.DisplayLayout.GroupByBox.BorderStyle = Infragistics.Win.UIElementBorderStyle.Solid;
			appearance4.BackColor = System.Drawing.SystemColors.ControlLightLight;
			appearance4.BackColor2 = System.Drawing.SystemColors.Control;
			appearance4.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
			appearance4.ForeColor = System.Drawing.SystemColors.GrayText;
			resources.ApplyResources(appearance4, "appearance34");
			resources.ApplyResources(appearance4.FontData, "appearance34.FontData");
			appearance4.ForceApplyResources = "FontData|";
			this.ultraGridEditor.DisplayLayout.GroupByBox.PromptAppearance = appearance4;
			this.ultraGridEditor.DisplayLayout.MaxColScrollRegions = 1;
			this.ultraGridEditor.DisplayLayout.MaxRowScrollRegions = 1;
			appearance5.BackColor = System.Drawing.SystemColors.Window;
			appearance5.ForeColor = System.Drawing.SystemColors.ControlText;
			resources.ApplyResources(appearance5, "appearance35");
			resources.ApplyResources(appearance5.FontData, "appearance35.FontData");
			appearance5.ForceApplyResources = "FontData|";
			this.ultraGridEditor.DisplayLayout.Override.ActiveCellAppearance = appearance5;
			this.ultraGridEditor.DisplayLayout.Override.BorderStyleCell = Infragistics.Win.UIElementBorderStyle.Dotted;
			this.ultraGridEditor.DisplayLayout.Override.BorderStyleRow = Infragistics.Win.UIElementBorderStyle.Dotted;
			appearance6.BorderColor = System.Drawing.Color.Silver;
			resources.ApplyResources(appearance6, "appearance36");
			appearance6.TextTrimming = Infragistics.Win.TextTrimming.EllipsisCharacter;
			resources.ApplyResources(appearance6.FontData, "appearance36.FontData");
			appearance6.ForceApplyResources = "FontData|";
			this.ultraGridEditor.DisplayLayout.Override.CellAppearance = appearance6;
			this.ultraGridEditor.DisplayLayout.Override.CellPadding = 0;
			appearance7.BackColor = System.Drawing.SystemColors.Control;
			appearance7.BackColor2 = System.Drawing.SystemColors.ControlDark;
			appearance7.BackGradientAlignment = Infragistics.Win.GradientAlignment.Element;
			appearance7.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
			appearance7.BorderColor = System.Drawing.SystemColors.Window;
			resources.ApplyResources(appearance7, "appearance37");
			resources.ApplyResources(appearance7.FontData, "appearance37.FontData");
			appearance7.ForceApplyResources = "FontData|";
			this.ultraGridEditor.DisplayLayout.Override.GroupByColumnAppearance = appearance7;
			resources.ApplyResources(appearance8, "appearance38");
			resources.ApplyResources(appearance8.FontData, "appearance38.FontData");
			appearance8.ForceApplyResources = "FontData|";
			this.ultraGridEditor.DisplayLayout.Override.HeaderAppearance = appearance8;
			this.ultraGridEditor.DisplayLayout.Override.HeaderStyle = Infragistics.Win.HeaderStyle.WindowsXPCommand;
			appearance9.BackColor = System.Drawing.SystemColors.Window;
			appearance9.BorderColor = System.Drawing.Color.Silver;
			resources.ApplyResources(appearance9, "appearance39");
			resources.ApplyResources(appearance9.FontData, "appearance39.FontData");
			appearance9.ForceApplyResources = "FontData|";
			this.ultraGridEditor.DisplayLayout.Override.RowAppearance = appearance9;
			appearance10.ImageAlpha = Infragistics.Win.Alpha.UseAlphaLevel;
			resources.ApplyResources(appearance10, "appearance41");
			resources.ApplyResources(appearance10.FontData, "appearance41.FontData");
			appearance10.ForceApplyResources = "FontData|";
			this.ultraGridEditor.DisplayLayout.Override.RowSelectorAppearance = appearance10;
			this.ultraGridEditor.DisplayLayout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.True;
			appearance11.BackColor = System.Drawing.SystemColors.ControlLight;
			resources.ApplyResources(appearance11, "appearance40");
			resources.ApplyResources(appearance11.FontData, "appearance40.FontData");
			appearance11.ForceApplyResources = "FontData|";
			this.ultraGridEditor.DisplayLayout.Override.TemplateAddRowAppearance = appearance11;
			this.ultraGridEditor.DisplayLayout.ScrollBounds = Infragistics.Win.UltraWinGrid.ScrollBounds.ScrollToFill;
			this.ultraGridEditor.DisplayLayout.ViewStyleBand = Infragistics.Win.UltraWinGrid.ViewStyleBand.OutlookGroupBy;
			this.ultraGridEditor.Name = "ultraGridEditor";
			this.ultraGridEditor.AfterCellActivate += new System.EventHandler(ultraGridEditor_AfterCellActivate);
			this.ultraGridEditor.InitializeLayout += new Infragistics.Win.UltraWinGrid.InitializeLayoutEventHandler(ultraGridEditor_InitializeLayout);
			this.ultraGridEditor.CellChange += new Infragistics.Win.UltraWinGrid.CellEventHandler(ultraGridEditor_CellChange);
			this.ultraGridEditor.DoubleClickCell += new Infragistics.Win.UltraWinGrid.DoubleClickCellEventHandler(ultraGridEditor_DoubleClickCell);
			this.ultraGridEditor.AfterSelectChange += new Infragistics.Win.UltraWinGrid.AfterSelectChangeEventHandler(ultraGridEditor_AfterSelectChange);
			this.btAdd.AccessibleDescription = null;
			this.btAdd.AccessibleName = null;
			resources.ApplyResources(this.btAdd, "btAdd");
			this.btAdd.BackgroundImage = null;
			this.btAdd.Font = null;
			this.btAdd.Name = "btAdd";
			this.btAdd.UseVisualStyleBackColor = true;
			this.btAdd.Click += new System.EventHandler(btAdd_Click);
			this.btCancel.AccessibleDescription = null;
			this.btCancel.AccessibleName = null;
			resources.ApplyResources(this.btCancel, "btCancel");
			this.btCancel.BackgroundImage = null;
			this.btCancel.Font = null;
			this.btCancel.Name = "btCancel";
			this.btCancel.UseVisualStyleBackColor = true;
			this.btCancel.Click += new System.EventHandler(btCancel_Click);
			this.btRemove.AccessibleDescription = null;
			this.btRemove.AccessibleName = null;
			resources.ApplyResources(this.btRemove, "btRemove");
			this.btRemove.BackgroundImage = null;
			this.btRemove.Font = null;
			this.btRemove.Name = "btRemove";
			this.btRemove.UseVisualStyleBackColor = true;
			this.btRemove.Click += new System.EventHandler(btRemove_Click);
			this.btOk.AccessibleDescription = null;
			this.btOk.AccessibleName = null;
			resources.ApplyResources(this.btOk, "btOk");
			this.btOk.BackgroundImage = null;
			this.btOk.Font = null;
			this.btOk.Name = "btOk";
			this.btOk.UseVisualStyleBackColor = true;
			this.btOk.Click += new System.EventHandler(btOk_Click);
			this.btAnalysis.AccessibleDescription = null;
			this.btAnalysis.AccessibleName = null;
			resources.ApplyResources(this.btAnalysis, "btAnalysis");
			this.btAnalysis.BackgroundImage = null;
			this.btAnalysis.Font = null;
			this.btAnalysis.Name = "btAnalysis";
			this.btAnalysis.UseVisualStyleBackColor = true;
			this.btAnalysis.Click += new System.EventHandler(btAnalysis_Click);
			base.AccessibleDescription = null;
			base.AccessibleName = null;
			resources.ApplyResources(this, "$this");
			base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.BackgroundImage = null;
			base.Controls.Add(this.btAnalysis);
			base.Controls.Add(this.btOk);
			base.Controls.Add(this.btRemove);
			base.Controls.Add(this.btCancel);
			base.Controls.Add(this.btAdd);
			base.Controls.Add(this.ultraGridEditor);
			this.Font = null;
			base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			base.Icon = null;
			base.MaximizeBox = false;
			base.MinimizeBox = false;
			base.Name = "Expression_Editor";
			base.ShowIcon = false;
			base.ShowInTaskbar = false;
			((System.ComponentModel.ISupportInitialize)this.ultraGridEditor).EndInit();
			((System.ComponentModel.ISupportInitialize)this.ultraDataSource1).EndInit();
			base.ResumeLayout(false);
		}

		public Expression_Editor(IApplication app, IRuleItem mRuleItem, string mSelectExpression, string mProjectName, int m_Pattern, int m_Target, int m_ExpressionCheck, int m_Operator, string m_Value)
		{
			InitializeComponent();
			mApplication = app;
			m_LPattern = m_Pattern;
			m_LTarget = m_Target;
			m_LOperator = m_Operator;
			m_LValue = m_Value;
			m_LExpressionCheck = m_ExpressionCheck;
			mResourceManager = ResourceManager.CreateFileBasedResourceManager("ExperimentRuleEditor", mApplication.GetResourceFolder() + GetType().Namespace + "\\", null);
			m_LRuleItem = mRuleItem;
			m_LSelectExpression = mSelectExpression;
			m_LProjectName = mProjectName;
			InitializeForm();
			mPcrLogService = (IPcrLogService)app.GetService("PcrLogService");
		}

		private void InitializeForm()
		{
			UltraDataSource ultraDataSource = new UltraDataSource();
			ultraDataSource.Band.Columns.Add("Expression Name");
			ultraDataSource.Band.Columns.Add("Expression Content");
			ultraDataSource.Band.Columns.Add("Display");
			ultraDataSource.Band.Columns["Display"].DataType = typeof(bool);
			object[] array = new object[3];
			int num = 0;
			if (m_LRuleItem.ExpressionEditorList != null)
			{
				foreach (IExressionEditor expressionEditor in m_LRuleItem.ExpressionEditorList)
				{
					array[0] = expressionEditor.Expression_Name;
					array[1] = expressionEditor.Expression_Content;
					array[2] = expressionEditor.Expression_Display;
					ultraDataSource.Rows.Add(array);
					num++;
				}
			}
			else
			{
				array[0] = string.Empty;
				array[1] = string.Empty;
				array[2] = false;
				ultraDataSource.Rows.Add(array);
			}
			((ISupportInitialize)ultraGridEditor).BeginInit();
			UltraGridBand ultraGridBand = new UltraGridBand("Band 0", -1);
			foreach (UltraDataColumn item in (IEnumerable)ultraDataSource.Band.Columns)
			{
				UltraGridColumn ultraGridColumn = new UltraGridColumn(item.Key);
				ultraGridColumn.Header.FixedHeaderIndicator = FixedHeaderIndicator.None;
				ultraGridColumn.AutoSizeMode = ColumnAutoSizeMode.AllRowsInBand;
				if (item.Key == "Expression Content")
				{
					ultraGridColumn.CellActivation = Activation.NoEdit;
				}
				ultraGridBand.Columns.Add(ultraGridColumn);
			}
			ultraGridBand.Columns["Expression Name"].Header.Caption = mResourceManager.GetString("ExpressionNameString");
			ultraGridBand.Columns["Expression Content"].Header.Caption = mResourceManager.GetString("ExpressionContentString");
			ultraGridBand.Columns["Display"].Header.Caption = mResourceManager.GetString("DisplayString");
			ultraGridEditor.DisplayLayout.BandsSerializer.Add(ultraGridBand);
			ultraGridEditor.DataSource = ultraDataSource;
			ultraGridEditor.UpdateMode = UpdateMode.OnUpdate;
			((ISupportInitialize)ultraGridEditor).EndInit();
		}

		private void ultraGridEditor_InitializeLayout(object sender, InitializeLayoutEventArgs e)
		{
			try
			{
				e.Layout.Override.CellClickAction = CellClickAction.EditAndSelectText;
				e.Layout.Override.CellAppearance.BackColor = Color.White;
				e.Layout.Override.AllowMultiCellOperations = AllowMultiCellOperation.None;
				e.Layout.Override.RowSizing = RowSizing.AutoFixed;
				e.Layout.ViewStyleBand = ViewStyleBand.Horizontal;
				e.Layout.Override.RowSelectors = DefaultableBoolean.True;
				e.Layout.Override.RowSelectorHeaderStyle = RowSelectorHeaderStyle.SeparateElement;
				e.Layout.Override.RowSelectorNumberStyle = RowSelectorNumberStyle.VisibleIndex;
				e.Layout.Override.RowSelectorStyle = HeaderStyle.Standard;
				e.Layout.Override.RowSelectorAppearance.TextHAlign = HAlign.Center;
				e.Layout.Override.RowSelectorAppearance.TextVAlign = VAlign.Middle;
				e.Layout.Override.RowSelectorAppearance.ImageAlpha = Alpha.Transparent;
				e.Layout.Override.ExpansionIndicator = ShowExpansionIndicator.Never;
				e.Layout.CaptionVisible = DefaultableBoolean.False;
				e.Layout.Override.ColumnAutoSizeMode = ColumnAutoSizeMode.AllRowsInBand;
				e.Layout.Override.AllowColMoving = AllowColMoving.NotAllowed;
				e.Layout.Override.AllowColSizing = AllowColSizing.None;
				e.Layout.Scrollbars = Scrollbars.Both;
				e.Layout.ScrollStyle = ScrollStyle.Immediate;
				e.Layout.Override.RowSizing = RowSizing.AutoFixed;
				e.Layout.Override.ColumnAutoSizeMode = ColumnAutoSizeMode.AllRowsInBand;
				e.Layout.Override.FilterClearButtonLocation = FilterClearButtonLocation.Row;
				e.Layout.Override.FilterOperandStyle = FilterOperandStyle.DropDownList;
				e.Layout.Override.FilterOperatorDropDownItems = FilterOperatorDropDownItems.Equals;
				e.Layout.Override.FilterOperatorDefaultValue = FilterOperatorDefaultValue.Equals;
				e.Layout.Override.FilterOperatorLocation = FilterOperatorLocation.Hidden;
				e.Layout.Override.RowFilterMode = RowFilterMode.SiblingRowsOnly;
				e.Layout.Override.SequenceFilterRow = 0;
				e.Layout.Override.SelectTypeCell = SelectType.Extended;
				e.Layout.Override.SelectTypeCol = SelectType.Extended;
				e.Layout.Override.SelectTypeRow = SelectType.Extended;
				e.Layout.UseFixedHeaders = true;
				e.Layout.Override.FixedHeaderIndicator = FixedHeaderIndicator.None;
				foreach (UltraGridColumn column in e.Layout.Bands[0].Columns)
				{
					column.PerformAutoResize(PerformAutoSizeType.AllRowsInBand);
					column.Width += 4;
				}
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
			}
		}

		private void ultraGridEditor_CellChange(object sender, CellEventArgs e)
		{
			if (!("Expression Name" == e.Cell.Column.Key))
			{
				bool flag = "Export" == e.Cell.Column.Key;
			}
		}

		private void ultraGridEditor_DoubleClickCell(object sender, DoubleClickCellEventArgs e)
		{
			try
			{
				if (e.Cell.Column.Key == "Expression Content")
				{
					EFormula eFormula = new EFormula(mApplication, e.Cell.Text, m_LProjectName, m_LPattern, m_LTarget, m_LOperator, m_LValue);
					if (eFormula.ShowDialog() == DialogResult.OK)
					{
						e.Cell.Value = eFormula.GetExpressionText;
						m_LPattern = eFormula.GetPatternIndex;
						m_LTarget = eFormula.GetTargetIndex;
						m_LOperator = eFormula.GetOperatorIndex;
						m_LValue = eFormula.GetValueIndex;
						e.Cell.Column.PerformAutoResize(PerformAutoSizeType.AllRowsInBand);
					}
				}
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
			}
		}

		private void btAdd_Click(object sender, EventArgs e)
		{
			try
			{
				ultraGridEditor.DisplayLayout.Bands[0].Columns["Display"].DefaultCellValue = false;
				ultraGridEditor.DisplayLayout.Bands[0].AddNew();
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
			}
		}

		private void btRemove_Click(object sender, EventArgs e)
		{
			try
			{
				int num = 0;
				if (m_LRuleItem.RuleEditorList != null)
				{
					foreach (IRuleEditor ruleEditor in m_LRuleItem.RuleEditorList)
					{
						foreach (IConditionEditor conditionEditor in ruleEditor.ConditionEditorList)
						{
							SelectedRowsCollection rows = ultraGridEditor.Selected.Rows;
							string text = rows[0].Cells["Expression Name"].Text;
							string[] array = conditionEditor.Condition.Split(' ');
							num = ((conditionEditor.ExpressionIndex <= 8) ? conditionEditor.ExpressionIndex : (conditionEditor.ExpressionIndex - 10));
							if (array[num] == text)
							{
								MessageBox.Show(mResourceManager.GetString("RowNotDeleteWithExpressionString"), mResourceManager.GetString("ErrorString"));
								return;
							}
						}
					}
					ultraGridEditor.DeleteSelectedRows(false);
					btRemove.Enabled = false;
				}
				else
				{
					ultraGridEditor.DeleteSelectedRows(false);
					btRemove.Enabled = false;
				}
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
			}
		}

		private void ultraGridEditor_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
		{
			try
			{
				if (ultraGridEditor.Selected.Rows.Count == 1)
				{
					btRemove.Enabled = true;
				}
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
			}
		}

		private void ultraGridEditor_AfterCellActivate(object sender, EventArgs e)
		{
			btRemove.Enabled = false;
		}

		private void btOk_Click(object sender, EventArgs e)
		{
			try
			{
				if (ExpressionJudge())
				{
					SaveRuleGrid(ultraGridEditor, m_LRuleItem);
					base.DialogResult = DialogResult.OK;
					Close();
				}
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
			}
		}

		private bool ExpressionJudge()
		{
			try
			{
				if (ultraGridEditor.Rows.Count == 0)
				{
					MessageBox.Show(mResourceManager.GetString("RowString") + "1" + mResourceManager.GetString("ExpressionDefiniationEmptyString"), mResourceManager.GetString("ErrorString"));
					return false;
				}
				for (int i = 0; i < ultraGridEditor.Rows.Count; i++)
				{
					if (ultraGridEditor.Rows[i].Cells["Expression Name"].Text == "")
					{
						MessageBox.Show(mResourceManager.GetString("RowString") + (i + 1) + mResourceManager.GetString("ExpressionDefiniationEmptyString"), mResourceManager.GetString("ErrorString"));
						return false;
					}
				}
				if (ultraGridEditor.Rows.Count > 1)
				{
					for (int j = 0; j < ultraGridEditor.Rows.Count; j++)
					{
						for (int k = j + 1; k < ultraGridEditor.Rows.Count; k++)
						{
							if (ultraGridEditor.Rows[j].Cells["Expression Name"].Text.CompareTo(ultraGridEditor.Rows[k].Cells["Expression Name"].Text) == 0 || ultraGridEditor.Rows[j].Cells["Expression Content"].Text.CompareTo(ultraGridEditor.Rows[k].Cells["Expression Content"].Text) == 0)
							{
								MessageBox.Show(mResourceManager.GetString("RowString") + (j + 1) + mResourceManager.GetString("NotAsRowString") + (k + 1) + mResourceManager.GetString("SameString") + "!", mResourceManager.GetString("ErrorString"));
								return false;
							}
						}
					}
				}
				return true;
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
				return false;
			}
		}

		private void btCancel_Click(object sender, EventArgs e)
		{
			Close();
		}

		private void btAnalysis_Click(object sender, EventArgs e)
		{
			if (ExpressionJudge())
			{
				SaveRuleGrid(ultraGridEditor, m_LRuleItem);
				Expression_Analysis expression_Analysis = new Expression_Analysis(mApplication, m_LRuleItem, m_LProjectName, true);
				expression_Analysis.ShowDialog();
			}
		}

		public bool SaveRuleGrid(UltraGrid grdExpression, IRuleItem mRuleItem)
		{
			List<IExressionEditor> list = new List<IExressionEditor>();
			foreach (UltraGridRow row in grdExpression.Rows)
			{
				if (!(row.Cells["Expression Name"].Text == ""))
				{
					IExressionEditor exressionEditor = new ExressionEditor();
					exressionEditor.Expression_Name = row.Cells[0].Text;
					exressionEditor.Expression_Content = row.Cells[1].Text;
					if (row.Cells[2].Text == "True")
					{
						exressionEditor.Expression_Display = true;
					}
					else
					{
						exressionEditor.Expression_Display = false;
					}
					list.Add(exressionEditor);
				}
			}
			mRuleItem.ExpressionEditorList = list;
			return true;
		}
	}
}
